
class Control: public Window
{

   HIMAGELIST iml; TRACKMOUSEEVENT tme;

public:

   int status; bool over;

   //
   void Initialize()
   {
      tme.cbSize = sizeof(tme); tme.dwFlags = TME_LEAVE; tme.dwHoverTime = 9;
      //4 icons
      HANDLE im = LoadImageA(hinst, MAKEINTRESOURCEA(5), 0, 0, 0, 0);
      iml = ImageList_Create(24, 24, ILC_COLOR24|ILC_MASK, 4, 0);
      ImageList_AddMasked(iml, (HBITMAP)im, RGB(255,0,0));
      DeleteObject(im);
      status = 0;
      over = false;
   }


   //
   int OnMouseMove(WPARAM wp, LPARAM lp)
   {
      if(!over)
      {
         if(status == 0) status = 1; else if(status == 2) status = 3;
         tme.hwndTrack = hwnd;
         if(TrackMouseEvent(&tme)) over = true;
         Invalidate();
      }
      return 0;
   }


   //
   int OnLButtonUp(WPARAM wp, LPARAM lp)
   {
      //deb("OnLButtonUp"); //nu se executa in cazul Butonului (doar pt ce e 'Window')
      if(status == 1) status = 3; else if(status == 3) status = 1;
      Invalidate();
      return 0;
   }


   //
   int OnMouseLeave()
   {
      if(status == 1) status = 0; else if(status == 3) status = 2;
      over = false;
      Invalidate();
      return 0;
   }


   //
   int OnPaint(HDC hdc)
   { 
      DrawStateA(hdc, 0, 0, (LPARAM)ImageList_GetIcon(iml, status, 0), 0, 0, 0, 24, 24, DST_ICON);
      return 1;
   }


};

